<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" >
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <title>Register</title>
</head>
<body>

<script src="./jquery-3.1.1.min.js"></script>
<script>

    var lastIndex = 0;
    var query = new XMLHttpRequest();
    query.onreadystatechange = function () {
        $('body').append('<div>'+query.readyState+'</div>');
        // if (query.readyState == 3) {
        //每次返回的数据responseText会包含上次的数据，所以需要手动substring一下

        var info = query.responseText;
        $('body').append('<div>'+info+'</div>');

        // lastIndex = query.responseText.length;
        //  }
    }
    query.open("GET", "http://localhost:8080/register?watch=1", true);

    query.send();

</script>
</body>
</html>